package com.catsic.mod.specification;

import org.apache.commons.lang.StringUtils;

import com.catsic.base.specification.BaseSpec;
import com.catsic.base.specification.QueryWraper;
import com.catsic.mod.condition.SendMessageCondition;
import com.catsic.mod.entity.SendMessage;

public class SendMessageSpec extends BaseSpec<SendMessage> {

	public SendMessageSpec(SendMessageCondition condition) {
		super(condition);
	}

	@Override
	protected void addCondition(QueryWraper<SendMessage> queryWraper) {
		SendMessageCondition condition=(SendMessageCondition) getCondition();
		if(StringUtils.isNotBlank(condition.getUserName())){
			addEqualCondition(queryWraper, queryWraper.getRoot().get("user").get("username"),condition.getUserName());
		}	
		if(StringUtils.isNotBlank(condition.getAddresseeName())){		
		addEqualCondition(queryWraper, queryWraper.getRoot().join("receiveMessages").get("receiveMessage").get("addresseeName"), condition.getAddresseeName());
		
		}
	}
}
